home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 106 / pascal / gdospas.doc < prev    next >
Encoding:
Internet Message Format  |  1987-02-20  |  6.0 KB

  1. Subject: GDOS and OSS/CCD Pascal 
  2.  
  3. There seem to be quite a lot of people which missed my posting a few months
  4. ago about getting OSS/CCD Personal Pascal programs to run with GDOS.
  5.  
  6. This is a post of a sample dummy program that shows how it should be done.
  7. I'm working on a larger posting that will include this file and a lot of
  8. other sample AES/VDI calls with a bit more documentation which should be
  9. finished soon.
  10.  
  11.                         Simon Poole
  12.  
  13. -------------------Cut Here-----------------------------------------------
  14. {*******************************************************************}
  15. {* Sample code for starting a OSS/CCD pascal program correctly     *}
  16. {* with resident GDOS (pulled from UniTerm code (c) Simon Poole)   *}
  17. {* !!!!! pls use only as sample and do your own testing!!!!!!!!!!! *}
  18. {*******************************************************************}
  19. Program The_Correct_Way;
  20.  
  21. Const
  22. {$I GEMCONST.PAS}
  23.  
  24. Type
  25. {$I GEMTYPE.PAS}
  26.     { Arrays for VDI and AES parameters/results }
  27.     Ctrl_Parms   = Array[0..11] Of Integer;
  28.     Int_In_Parms = Array[0..15] Of Integer;
  29.     Int_Out_Parms = Array[0..45] Of Integer;
  30.     Pts_In_Parms = Array[0..11] Of Integer;
  31.     Pts_Out_Parms = Array[0..11] Of Integer;
  32.  
  33.  
  34. Var
  35.     Control : Ctrl_Parms;
  36.     Int_In : Int_In_Parms;
  37.     Int_Out : Int_Out_Parms;
  38.     Pts_In : Pts_In_Parms;
  39.     Pts_Out : Pts_Out_Parms;
  40.  
  41.     Graf_Handle : Integer;
  42.  
  43. {$I GEMSUBS.PAS}
  44.  
  45.     {**************************************************************}
  46.     {*                                                            *}
  47.     {*  CCD/OSS Pascal    VDI trap handler                        *}
  48.     {*                                                            *}
  49.     {**************************************************************}
  50.     Procedure VDI_Call(Cmd, SubCmd : Integer; N_Ints, N_Pts : Integer;
  51.                        Var Control : Ctrl_Parms;
  52.                        Var Int_In : Int_In_Parms;
  53.                        Var Int_Out : Int_Out_Parms;
  54.                        Var Pts_In : Pts_In_Parms;
  55.                        Var Pts_Out : Pts_Out_Parms;
  56.                        Translate : boolean);
  57.     External;
  58.  
  59.     {**************************************************************}
  60.     {*                                                            *}
  61.     {*  This procedure sets the internal device handle            *}
  62.     {*                                                            *}
  63.     {**************************************************************}
  64.     Procedure G_Set_Port(Handle : Integer);
  65.     External;
  66.  
  67.     {**************************************************************}
  68.     {*                                                            *}
  69.     {*  This function gets the internal device handle             *}
  70.     {*                                                            *}
  71.     {**************************************************************}
  72.     Function Get_Port : Integer;
  73.     External;
  74.  
  75.     Procedure OpenVirtualWorkStation(Var Handle,PixelX,PixelY,PixelW,PixelH,
  76.                                        Colors : Integer);
  77.  
  78.        Var i : Integer;
  79.  
  80.  
  81.        Begin
  82.  
  83.           For i := 0 To 9 Do Int_In[i] := 1;
  84.           Int_In[10] := 2;
  85.           VDI_Call(100,0,11,0,Control,Int_In,Int_Out,Pts_In,Pts_Out,False);
  86.           Handle := Control[6];
  87.           PixelX := Int_Out[0];
  88.           PixelY := Int_Out[1];
  89.           PixelW := Int_Out[3];
  90.           PixelH := Int_Out[4];
  91.           Colors := Int_Out[13];
  92.        End;
  93.  
  94.  
  95.     Procedure OpenWorkStation(Var Device : Integer);
  96.  
  97.        Var i : Integer;
  98.  
  99.        Begin
  100.           For i := 1 To 9 Do Int_In[i] := 1;
  101.           Int_In[0] := Device;
  102.           Int_In[10] := 2;   {Raster coordinates}
  103.           VDI_Call(1,0,11,0,Control,Int_In,Int_Out,Pts_In,Pts_Out,False);
  104.           Device := Control[6];
  105.        End;
  106.  
  107.  
  108.     Procedure CloseVirtualWorkStation;
  109.  
  110.        Var i : Integer;
  111.  
  112.        Begin
  113.           VDI_Call(101,0,0,0,Control,Int_In,Int_Out,Pts_In,Pts_Out,False);
  114.        End;
  115.  
  116.  
  117.     Procedure CloseWorkStation;
  118.  
  119.        Var i : Integer;
  120.  
  121.  
  122.        Begin
  123.           VDI_Call(2,0,0,0,Control,Int_In,Int_Out,Pts_In,Pts_Out,False);
  124.        End;
  125.  
  126.  
  127.     {**************************************************************}
  128.     {*                                                            *}
  129.     {*  Replacement for Init_Gem                                  *}
  130.     {*                                                            *}
  131.     {**************************************************************}
  132.     Function InitGEM : Integer;
  133.  
  134.        Var Ap_Id : Integer;
  135.  
  136.        Begin
  137.           Ap_Id := Init_Gem;
  138.           If Ap_Id >= 0 Then Begin {Appl_Init worked OK}
  139.              Graf_Handle := Graf_Hdl(Dummy,Dummy,Dummy,Dummy);
  140.              If Get_Port = 0 Then Begin {If the internal handle is 0}
  141.                 G_Set_Port(Graf_Handle);{OSS messed it up!          }
  142.                 {The internal version failed, so do it ourselves    }
  143.                 OpenVirtualWorkStation(Graf_Handle,
  144.                    Dummy,Dummy,Dummy,Dummy,Dummy);
  145.                 {Set the internal handle to the correct value       }
  146.                 G_Set_Port(Graf_Handle);
  147.              End
  148.           End
  149.           InitGEM := Ap_Id
  150.        End;
  151.  
  152.  
  153.     {**************************************************************}
  154.     {*                                                            *}
  155.     {*  Replacement for Exit_Gem                                  *}
  156.     {*                                                            *}
  157.     {**************************************************************}
  158.     Procedure ExitGEM;
  159.  
  160.        Begin
  161.           Exit_Gem;
  162.           {The following call should really only be used if GDOS is}
  163.           {really there, but it doesn't seem to hurt               }
  164.           CloseVirtualWorkstation;
  165.        End;
  166.  
  167.  
  168. Begin {Main}
  169.    If InitGEM >= 0 Then Begin
  170.       {Do something here}
  171.       ExitGEM
  172.    End
  173. End.
  174.